﻿
@{
    ViewData["Title"] = "Home Page";
}

<div class="container">
    <div class="row">
        <div class="col-md-12">
            <button class="btn btn-primary" onclick="overdue()">作废</button>

        </div>
    </div>
    <div class="row" id="pros">     

    </div>
    <div>
        <span id="message"></span>
    </div>
</div>
@section Scripts{

    <script>

        function getProjects() {
            $.get("/projects", function (projects) {
                $("#pros").html('');
                $.each(projects, function (index, ele) {
                    $("#pros").append('<p style="margin-top:20px"> <button class="btn btn-success" onclick="goto(\'' + ele.url + '\')" >' + ele.name + '</button>&nbsp <button class="btn btn-default" onclick="read(\'' + ele.code + '\')">' + ele.name + '</button>       </p>');
                })
            })
        }
        $(function () {
            getProjects();
            setInterval(getProjects, 10000);            
        })

        function overdue() {
            //$.get("http://localhost:5000/overdue", function (result) {
            //    console.log(result);
            //})
            $.get("/overdue", function (result) {
                console.log(result);
            })
        }
        function read(code) {
            $.get("/read", { code: code }, function (result) {
                $("#message").html(result);
            })
        }
        function goto(url) {
            window.open(url, "_blank");
        }
    </script>
}
